home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: EnglishToIntl */
- /* */
- /* File Name: EnglishToIntl.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-08-12 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "string.h"
- #include "TextUtils.h"
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rConfigDLOG 10000
- #define kConfig 3
- #define kLanguage 4
-
- /****************************************** PROTOTYPES ******************************************/
-
- short GetConfigString (Str255 config, short *lang);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short GetConfigString (Str255 config, short *lang)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 tStr;
- long tLong;
-
- if ((theDialog = GetNewDialog (rConfigDLOG, nil, (WindowPtr)(-1L))) != nil) {
-
- GetDItem (theDialog, kConfig, &itemKind, &itemHand, &itemRect);
- setitext (itemHand, config);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if (itemHit == ok) {
- GetDItem (theDialog, kConfig, &itemKind, &itemHand, &itemRect);
- getitext (itemHand, config);
-
- GetDItem (theDialog, kLanguage, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, tStr);
- StringToNum (tStr, &tLong);
- *lang = tLong;
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- OSErr errCode;
- Str255 inputPtr; // we are assuming config string won't be > 256 chars
- Ptr outputPtr, tPtr;
- short lang, itemHit;
-
- tPtr = TELGetConfig (termHand);
- if (tPtr) {
- strcpy (inputPtr, tPtr);
- DisposPtr (tPtr);
- }
-
- if ((itemHit = GetConfigString (inputPtr, &lang)) == ok) {
-
- if ((errCode = TELEnglishToIntl (termHand, inputPtr, &outputPtr, lang)) == noErr) {
- Print (paramPtr, " EnglishToIntl --> %s", outputPtr);
-
- if (outputPtr)
- DisposPtr (outputPtr);
- }
- else
- Print (paramPtr, "### TELEnglishToIntl fails : %d", errCode);
- }
- }
-
-
-